﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace TempEmployees.Web
{
    public partial class ErrorPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Exception ex = null;
                try
                {
                    ex = APageData.Get<ErrorPageData>().Error;
                    APageData.Remove<ErrorPageData>();
                }
                catch { }

                string sessionId = (Session != null) ? Session.SessionID : "No session";
                LabelSessionID.Text = string.Format("Session ID: {0}", sessionId);

                if (ex != null)
                {
                    LabelExMessage.Text = string.Format("Message: {0}", ex.Message);
                    LabelExType.Text = string.Format("Type: {0}", ex.GetType());
                    LabelExData.Text = string.Format("Data: {0}", ex.Data);
                    LabelExSource.Text = string.Format("Source: {0}", ex.Source);
                    LabelStackTrace.Text = ex.StackTrace.Replace("\n\r", "</br>");
                }
            }
        }
    }

    public class ErrorPageData : APageData
    {
        public Exception Error { get; private set; }

        public ErrorPageData(Exception e)
        {
            Error = e;
        }
    }
}
